package lab03.test06;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.HashMap;
import java.util.Map;


    public class Test06 {

        public static void main(String[] args) {
            String path="F:\\新建文本文档.txt";
            try {
                RandomAccessFile file=new RandomAccessFile(path,"rw");
                String line=null;
                Map map=new HashMap();
                try {
                    int value = 0;
                    while ((line = file.readLine()) != null) {
                        if (map.get(line) == null) {
                            map.put(line, 1);
                        } else {
                            value = (int) map.get(line);
                            value = value + 1;
                            map.put(line, value);
                        }
                    }
                    System.out.println(map);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }

